package cn.com.sparkle.paxos.net.factory.raptor;

import com.google.protobuf.GeneratedMessage;

import cn.com.sparkle.paxos.net.factory.NetCloseException;
import cn.com.sparkle.paxos.net.factory.PaxosSession;
import cn.com.sparkle.raptor.core.protocol.MultiThreadProtecolHandler.ProtocolHandlerIoSession;
import cn.com.sparkle.raptor.core.transport.socket.nio.exception.SessionHavaClosedException;

public class RaptorPaxosSession extends PaxosSession {
	ProtocolHandlerIoSession session;
	public RaptorPaxosSession(ProtocolHandlerIoSession session){
		this.session = session;
	}
	@Override
	public void write(GeneratedMessage message) throws NetCloseException {
		try {
			session.writeObject(message);
		} catch (SessionHavaClosedException e) {
			throw new NetCloseException(e);
		}
	}
	@Override
	public void closeSession() {
		session.closeSession();
	}
}
